package baidu.lib.utils
{

    public class StringTemplate extends Object
    {

        public function StringTemplate()
        {
            return;
        }

		
		public static function output(arg1:String, ... rest):String
		{
			var args:Array;
			var result:String;
			var template:String;
			
			var loc1:*;
			template = arg1;
			args = rest;
			if (template == null)
			{
				return "";
			}
			if (args.length < 1)
			{
				return template;
			}
			result = template.replace(new RegExp("\\${(\\w+)}", "g"), function ():String
			{
				var loc4:*=undefined;
				var loc1:*=arguments[1];
				var loc2:*=Number(loc1);
				var loc3:*="";
				if (isNaN(loc2))
				{
					if (args[0][loc1] != null)
					{
						loc3 = args[0][loc1].toString();
					}
				}
				else 
				{
					if ((loc4 = args[loc2]) != null)
					{
						loc3 = loc4.toString();
					}
				}
				return loc3;
			})
			return result;
		}

    }
}
